package service

import (
	"context"
	"gitee.com/kelvins-io/kelvins-template-cron/util/email"
	"gitee.com/kelvins-io/kelvins-template-cron/vars"
	"log"
	"strings"
	"sync"
	"time"
)

var (
	one sync.Once
)

func EchoTime() {
	log.Println("echo-time:", time.Now())
	// some services handle
	if vars.EmailNoticeSetting != nil {
		one.Do(func() {
			go func() {
				err := email.SendEmailNotice(context.TODO(), strings.Join(vars.EmailNoticeSetting.Receivers, ","), "kelvins-template-cron", "kelvins-template-cron服务测试")
				if err != nil {
					log.Printf("send email to(%+v) err %v\n", vars.EmailNoticeSetting, err)
				}
			}()
		})
	}

}
